

export default class PlayerPrefs {

    /**获取Int类型数据 */
    public static GetInt(valueName: string, defaultvalue: number) {
        var jsonData = Laya.LocalStorage.getItem(valueName);
        if (jsonData == null || jsonData == '')
            return defaultvalue;
        var d = Number(jsonData);
        return d;
    }

    /**设置Int类型数据 */
    public static SetInt(valueName: string, valuenum: number) {
        let valuestr = JSON.stringify(valuenum);
        Laya.LocalStorage.setItem(valueName, valuestr);
    }

    /**获取Sytring类型数据 */
    public static GetStr(valueName: string, defaultvalue: string) {
        var jsonData = Laya.LocalStorage.getItem(valueName);
        if (jsonData == null || jsonData == '')
            return defaultvalue;
    }

    /**设置String类型数据 */
    public static SetStr(valueName: string, valuestr: string) {
        Laya.LocalStorage.setItem(valueName, valuestr);
    }

    /**获取Sytring类型数据 */
    public static GetPlayerData(valueName: string, defaultvalue: any) 
    {
        var jsonData = Laya.LocalStorage.getItem(valueName);
        if (jsonData == null || jsonData =='')
            return defaultvalue;
        let data=JSON.parse(jsonData);
        return data;
    }

    /**设置Int类型数据 */
    public static SetPlayerData(valueName: string, valuedata: any) {
        let datastr=JSON.stringify(valuedata);
        Laya.LocalStorage.setItem(valueName, datastr);
    }

}